import React,{ useState, useEffect } from 'react'
import axios from 'axios'
import { Row, Col, Spin } from 'antd'  
import ContentIndex from './centerContent/index'
import RightAids from './rightAids/rightAids'

import Header from '../components/Header'

import './index.scss'
const Home = () => {
  // console.log(props,"111111111111111111111111111111111111111111");
  
  const [ mylist , setMylist ] = useState([]);
  const [spinning, setSpinning] = useState(false); // loading
  useEffect(() => {
    getArticleList()
  },[])
  const getArticleList = ()=> {
    setSpinning(true)
    axios('http://127.0.0.1:7001/default/getArticleList').then(
      (res)=>{
        setMylist(res.data.data)
        setSpinning(false)
      }
    )
  }
  return (
    <div className="appBox">
      <Header />
      <Spin tip="Loading..." spinning={ spinning }>
        <Row className="left-nav" type="flex" justify="space-around">
          {/* <Col xs={0} sm={0} md={0} lg={0} xl={0}>
            <LeftNav />
          </Col> */}
          <Col xs={22} sm={18} md={15} lg={15} xl={16} style={{background:'#fff'}}>
            <ContentIndex mylistData= {mylist} />
          </Col>
          <Col  xs={0} sm={4} md={7} lg={7} xl={6}>
            <RightAids />
          </Col>
        </Row>
      </Spin>
    </div>
  )
}
// Home.getInitialProps = async (context) => {
//   let baiduData = []
//   const promise = new Promise((resolve)=>{
//     axios('http://127.0.0.1:7001/default/getArticleList').then(
//       (res)=>{
//         // console.log(res.data,"666666666666",baiduData)
//         resolve(res.data)
//       }
//     )
//   })
//   return await promise
// }
export default Home
